package com.lsq.tucao.express.controller;

import com.lsq.tucao.express.bean.po.TucaoDiscuss;
import com.lsq.tucao.express.response.JsonResult;
import com.lsq.tucao.express.service.TucaoDiscussService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/tucao-discuss")
public class TucaoDiscussController {

    @Autowired
    private TucaoDiscussService tucaoDiscussService;

    /**
     * @author lsq
     * @description 分页获取某条吐槽的评论数据
     * @param current 页码
     * @param size 每页条数
     * @param tucaoId 吐槽id
     * @return com.lsq.tucao.express.response.JsonResult
     * @create 2021/4/20 16:19
     */
    @GetMapping("/page")
    public JsonResult getPageDiscussByTucaoId(@RequestParam(required = false,defaultValue = "1") Integer current,
                                     @RequestParam(required = false,defaultValue = "5") Integer size,
                                     @RequestParam Long tucaoId){
        log.debug("current:{}",current);
        log.debug("size:{}",size);
        log.debug("tucaoId:{}",tucaoId);

        return tucaoDiscussService.getPageDiscussByTucaoId(current,size,tucaoId);
    }

    /**
     * @author lsq
     * @description 发表吐槽评论
     * @param tucaoDiscuss 吐槽评论实体类
     * @return com.lsq.tucao.express.response.JsonResult
     * @create 2021/4/20 16:25
     */
    @PostMapping
    public JsonResult addDiscuss(@RequestBody TucaoDiscuss tucaoDiscuss){
        log.debug("tucaoDiscuss:{}",tucaoDiscuss);

        return tucaoDiscussService.addDiscuss(tucaoDiscuss);
    }

}
